#ifndef __VOL_MFC_UI_SCINTILLA_H__
#define __VOL_MFC_UI_SCINTILLA_H__

#include "Scintilla.h"
#include "ILoader.h"
#include "SciLexer.h"

class IScintillaEventListener : public IBaseEventListener
{
public:
    virtual void OnSavePointChange () = 0;
    virtual void OnSavePointLeft () = 0;
    virtual void OnModifyAttemptRo () = 0;
	virtual void OnMarginLeftClick (int modifiers, Sci_Position position, int margin) = 0;
	virtual void OnMarginRightClick (int modifiers, Sci_Position position, int margin) = 0;
	virtual void OnAutocSelection (Sci_Position position, const char *text, int ch, int listCompletionMethod) = 0;
	virtual void OnUserListSelection (int listType, Sci_Position position, const char *text, int ch, int listCompletionMethod) = 0;
	virtual void OnMacroRecord (int message, uptr_t wParam, sptr_t lParam) = 0;
//	virtual void OnCharAdded (int characterSource, int ch) = 0;
	virtual void OnCharAdded (int ch) = 0;
	virtual void OnDoubleClick (Sci_Position position, Sci_Position line, int modifiers) = 0;
	virtual void OnUpdateUI (int updated) = 0;
    virtual void OnPainted () = 0;
    virtual void OnDwellStart (Sci_Position position, int x, int y) = 0;
    virtual void OnDwellEnd (Sci_Position position, int x, int y) = 0;
    virtual void OnZoom () = 0;
    virtual void OnHotspotClick (Sci_Position position, int modifiers) = 0;
    virtual void OnHotspotDoubleClick (Sci_Position position, int modifiers) = 0;
    virtual void OnHotspotReleaseClick (Sci_Position position, int modifiers) = 0;
    virtual void OnIndicatorClick (Sci_Position position, int modifiers) = 0;
    virtual void OnIndicatorRelease (Sci_Position position, int modifiers) = 0;
    virtual void OnCallTipClick (Sci_Position position) = 0;
    virtual void OnAutoCCancelled () = 0;
    virtual void OnAutoCCharDeleted () = 0;
	virtual void OnAutoCCompleted (Sci_Position position, const char *text, int ch, int listCompletionMethod) = 0;
	virtual void OnAutoCSelectionChange (int listType, const char* text, Sci_Position position) = 0;
	//MOD
	virtual void OnChangeLineState (Sci_Position line, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnInsertText (Sci_Position position, Sci_Position length, const char* text, Sci_Position linesAdded, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnDeleteText (Sci_Position position, Sci_Position length, const char* text, Sci_Position linesAdded, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnChangeStyle (Sci_Position position, Sci_Position length, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnChangeFold (Sci_Position line, int foldLevelNow, int foldLevelPrev, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnChangeMarker (Sci_Position line, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnInsertCheck (Sci_Position position, Sci_Position length, const char* text, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
	virtual void OnChangeMargin (Sci_Position line, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
	virtual void OnChangeAnnotation (Sci_Position line, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
	virtual void OnChangeEolAnnotation (Sci_Position line, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
	virtual void OnChangeTabStops (Sci_Position line, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnBeforeInsert (Sci_Position position, Sci_Position length, const char* text, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnBeforeDelete (Sci_Position position, Sci_Position length, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnChangeIndicator (Sci_Position position, Sci_Position length, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnLexerState (Sci_Position position, Sci_Position length, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
    virtual void OnContainer (int token, int eventSoure, bool multiStep, bool lastStep, bool startAction) = 0;
};

class CVWnd_Scintilla : public CWnd
{
    DECLARE_VOL_NATIVE_WND_CLASS (CVWnd_Scintilla, CWnd, IScintillaEventListener, FALSE)
	
private:
	SciFnDirect m_fnDirect;
	sptr_t m_ptrDirect;
	
    afx_msg void OnSavePointChange (NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnSavePointLeft (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnModifyAttemptRo (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnModified (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnMarginLeftClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnMarginRightClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnAutocSelection (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnUserListSelection (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnMacroRecord (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnCharAdded (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDoubleClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnUpdateUI (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnPainted (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDwellStart (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDwellEnd (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnZoom (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnHotspotClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnHotspotDoubleClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnHotspotReleaseClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnIndicatorClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnIndicatorRelease (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnCallTipClick (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnAutoCCancelled (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnAutoCCharDeleted (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnAutoCCompleted (NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnAutoCSelectionChange (NMHDR* pNMHDR, LRESULT* pResult);
	
    DECLARE_MESSAGE_MAP ()
public:
	~CVWnd_Scintilla ();
	BOOL CreateScintilla (CVolNativeWndCreateParam* pCreateParam);
	sptr_t SendEditor (unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0);

	static void RegisterScintilla();
	static void ReleaseScintilla();
};

#endif